﻿using Entity.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace Entity.Models.Entities
{
    /// <summary>
    /// 工作流步骤表
    /// </summary>
    public class WorkFlow_InstanceStep : BaseEntity
    {
        /// <summary>
        /// 工作流实例Id
        /// </summary>
        [Column(TypeName = "varchar(36)")]
        public string InstanceId { get; set; }
        /// <summary>
        /// 审核人Id
        /// </summary>
        [Column(TypeName = "varchar(36)")]
        public string ReviewerId { get; set; }
        /// <summary>
        /// 审核理由
        /// </summary>
        [Column(TypeName = "varchar(64)")]
        public string ReviewReason { get; set; }
        /// <summary>
        /// 审核状态
        /// </summary>
        public WorkFlow_InstanceEnums.WorkFlow_InstanceStepEnums ReviewStatus { get; set; }
        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime ReviewTime { get; set; }
        /// <summary>
        /// 上一个步骤Id
        /// </summary>
        [Column(TypeName = "varchar(36)")]
        public string BeforeStepId { get; set; }
        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        public WorkFlow_InstanceStep(WorkFlow_Instance workFlow_Instance,string reviewerId)
        {
            Id = Guid.NewGuid().ToString();
            InstanceId = workFlow_Instance.Id;
            ReviewerId = reviewerId;
            ReviewReason = workFlow_Instance.Reason;
            ReviewStatus = WorkFlow_InstanceEnums.WorkFlow_InstanceStepEnums.EXAMINATION;
            CreateTime = DateTime.Now;
        }

        public WorkFlow_InstanceStep(WorkFlow_InstanceStep workFlow_Instance, string reviewerId)
        {
            Id = Guid.NewGuid().ToString();
            InstanceId = workFlow_Instance.InstanceId;
            ReviewerId = reviewerId;
            ReviewReason = workFlow_Instance.ReviewReason;
            BeforeStepId = workFlow_Instance.Id;
            ReviewStatus = WorkFlow_InstanceEnums.WorkFlow_InstanceStepEnums.EXAMINATION;
            CreateTime = DateTime.Now;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="instanceId">实例id</param>
        /// <param name="reviewReason">理由</param>
        /// <param name="beforeStepId">上一步骤</param>
        /// <param name="reviewerId">审核人</param>
        public WorkFlow_InstanceStep(string instanceId, string reviewReason, string beforeStepId, string reviewerId)
        {
            Id = Guid.NewGuid().ToString();
            InstanceId = instanceId;
            ReviewerId = reviewerId;
            ReviewReason = reviewReason;
            BeforeStepId = beforeStepId;
            ReviewStatus = WorkFlow_InstanceEnums.WorkFlow_InstanceStepEnums.REJECTED;
            CreateTime = DateTime.Now;
        }

        public WorkFlow_InstanceStep()
        {
        }
    }
}
